package com.huangcy.gulimall.seckill.controller;

import com.huangcy.common.utils.R;
import com.huangcy.gulimall.seckill.service.SeckillService;
import com.huangcy.gulimall.seckill.to.SeckillSkuRedisTo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @program: gulimall
 * @description:
 * @author: huangcy
 * @create: 2022-09-20 14:26
 **/
@RestController
public class SeckillController {


    @Autowired
    SeckillService seckillService;

    /**
     * .
     * 返回当前时间可以参与秒杀商品信息
     *
     * @return
     */
    @GetMapping("/currentSeckillSkus")
    private R getCurrentSeckillSkus() {
        List<SeckillSkuRedisTo> vos = seckillService.getCurrentSeckillSkus();
        return R.ok().setData(vos);
    }

    @GetMapping("/sku/seckill/{skuId}")
    public R getSkuSeckillInfo(@PathVariable("skuId") Long skuId) {

        SeckillSkuRedisTo to = seckillService.getSkuSeckillInfo(skuId);
        return R.ok().setData(to);
    }
}
